*Extract variables from HMRC FAME*

*FAME: 2000-2009

forv i=0/8 {

local j=`i'+1 

insheet using "H:\FAME\FAME Updated July 14\FAME0`i'0`j'.tab", clear

drop if identifier==.

qui keep identifier cons_code cost_of_sales depreciation exch_rate_from_local_curr ///
fixed_assets gross_profit no_employees ///
group_loans_asset group_loans_long_term group_loans_short_term ///
intangible_assets interest_paid long_term_debt quiscore  ///
no_of_months overseas_turnover research_and_development total_assets turnover ///
uk_turnover wages_and_salaries company_status company_type incorporation_date ///
primary_uk_sic_code short_term_loans_overdrafts

gen year=200`i'

save "${hmrc_datadir}\FAME\fame200`i'", replace

}

insheet using "H:\FAME\FAME Updated July 14\FAME0910.tab", clear

drop if identifier==.

qui keep identifier cons_code cost_of_sales depreciation exch_rate_from_local_curr ///
fixed_assets gross_profit no_employees ///
group_loans_asset group_loans_long_term group_loans_short_term ///
intangible_assets interest_paid long_term_debt quiscore  ///
no_of_months overseas_turnover research_and_development total_assets turnover ///
uk_turnover wages_and_salaries company_status company_type incorporation_date ///
primary_uk_sic_code short_term_loans_overdrafts

gen year=2009

save "${hmrc_datadir}\FAME\fame2009", replace


*FAME: 2010-2013

foreach i of numlist 0 2 {
local j=`i'+1

insheet using "H:\FAME\FAME Updated July 14\FAME_1`i'1`j'.tab", clear

qui drop if identifier==.

qui keep identifier cons_code cost_of_sales depreciation exch_rate_from_local_curr ///
fixed_assets gross_profit no_employees ///
group_loans_asset group_loans_long_term group_loans_short_term ///
intangible_assets interest_paid long_term_debt quiscore  ///
no_of_months overseas_turnover research_and_development total_assets turnover ///
uk_turnover wages_and_salaries company_status company_type incorporation_date ///
primary_uk_sic_code short_term_loans_overdrafts

gen year=201`i'

save "${hmrc_datadir}\FAME\fame201`i'", replace
}


insheet using "H:\FAME\FAME Updated July 14\LN_FAME_1112.csv", clear
qui drop if identifier==.

qui keep identifier cons_code cost_of_sales depreciation exch_rate_from_local_curr ///
fixed_assets gross_profit no_employees ///
group_loans_asset group_loans_long_term group_loans_short_term ///
intangible_assets interest_paid long_term_debt quiscore  ///
no_of_months overseas_turnover research_and_development total_assets turnover ///
uk_turnover wages_and_salaries company_status company_type incorporation_date ///
primary_uk_sic_code short_term_loans_overdrafts

gen year=2011

save "${hmrc_datadir}\FAME\fame2011", replace
